home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
varia
/
rpc.lha
/
dynload
/
loaderPrivate.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
2KB
|
91 lines
// Copyright (C) 1990 by Glenn Gribble; all rights are reserved.
// This program may be used for any purposes including inclusion in
// for profit programs. If the source is copied, the copyright notice
// must be included. Please send bug fixes/reports to glenn@synaptics.com
// This program is distributed without any warranty.
// -*- C++ -*-
// %W% %G%
#ifndef LOADERPRIVATE_H
#define LOADERPRIVATE_H
// For some reason, Sun did not put this in sys/mman.h
extern "C" int mprotect(caddr_t addr, int len, int prot);
// This is what the __DYNAMIC structure is. Found in <link.h>
extern link_dynamic _DYNAMIC;
// Set the n_type field of an nlist to N_SET when the value is known good
#define N_SET N_TYPE
typedef unsigned char *memptr;
// An encapsulation of the symbol table in a file
class symTable {
friend symTable* loadSymTable(const char *fn, bool wholeFile);
nlist *realSymbols;
int numRealSymbols;
nlist **quickSymbols;
int numQuickSymbols;
#ifdef sun3
void showReloc(reloc_info_68k *rl, int size, memptr seg);
bool doReloc(reloc_info_68k *rl, int size, memptr seg);
#endif
#ifdef sun4
void showReloc(reloc_info_sparc *rl, int size, memptr seg);
bool doReloc(reloc_info_sparc *rl, int size, memptr seg);
#endif
void fixup(char *strBase);
bool mapit();
bool copyin();
nlist *lookup(const char *name); // Just find a symbol in table
nlist *value(nlist *v); // fix nlist entry
symTable(const char *fn, bool wholeFile);
char *FileName;
bool good;
public:
~symTable();
static symTable *top;
const char *fileName() { return FileName; }
long data_offset;
long text_offset;
symTable *prev;
exec E;
nlist *value(const char *name); // Find and fix symbol in table
nlist *value(int indx); // Fix symbol at indx in table
void printAll();
};
class segment {
memptr _data;
int _prot;
int _len;
public:
segment(memptr d, int l, int p) { _data =d; _len=l; _prot=p; }
segment(int l, int p=PROT_READ|PROT_WRITE|PROT_EXEC);
memptr data() { return _data; }
int prot() { return _prot; }
int len() { return _len; }
void setProt(int newprot);
void unmap();
};
inline int debugSymbols() { return d_symbols || d_all; }
inline int debugRelocation() { return d_relocation || d_all; }
inline int debugExecs() { return d_execs || d_all; }
inline int debugConstructors() { return d_ctors || d_all; }
#endif LOADERPRIVATE_H